<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>JS时间</title>
</head>
<body>
	








	<script>
	var date = new Date('2016-10-20 15:18:03');
	console.log(date.getDay())
		//获得本周的周一和周末  
		function getThisWeekDate(date){  
		    var now = new Date(date);  
		    var week=new Array();  
		    var currentWeek = now.getDay();  
		    if ( currentWeek == 0 ){  
		        currentWeek = 7;  
		    }  
		   
		    var monday = now.getTime() -(currentWeek-1)*24*60*60*1000;  //星期一  
		    var tuesday  =now.getTime() - (currentWeek-2)*24*60*60*1000; //星期二  
		    var wednesday = now.getTime() -(currentWeek-3)*24*60*60*1000; //星期三  
		    var thursday = now.getTime() -(currentWeek-4)*24*60*60*1000; //星期四  
		    var friday  =now.getTime() - (currentWeek-5)*24*60*60*1000; //星期五  
		    var saturday = now.getTime() -(currentWeek-6)*24*60*60*1000; //星期六  
		    var sunday = now.getTime() +(7-currentWeek)*24*60*60*1000;     //星期日  
		   
		    week=weektoday(monday,tuesday,wednesday,thursday,friday,saturday,sunday);  
		   
		    return week;   
		}  

		function getNextWeekDate(date){  
		    var now = new Date(date);  
		    var week=new Array();  
		   
		    var currentWeek = now.getDay();  
		   
		    if ( currentWeek == 0 ) {  
		        currentWeek = 7;  
		    }  
		    var monday = now.getTime() -(currentWeek-8)*24*60*60*1000;  //星期一  
		    var tuesday= now.getTime() -(currentWeek-9)*24*60*60*1000;  //星期二  
		    var wednesday = now.getTime() -(currentWeek-10)*24*60*60*1000; //星期三  
		    var thursday = now.getTime() -(currentWeek-11)*24*60*60*1000; //星期四  
		    var friday= now.getTime() -(currentWeek-12)*24*60*60*1000; //星期五  
		    var saturday = now.getTime() -(currentWeek-13)*24*60*60*1000; //星期六  
		    var sunday = now.getTime() -(currentWeek-14)*24*60*60*1000; //星期日  
		   
		   
		    week=weektoday(monday,tuesday,wednesday,thursday,friday,saturday,sunday);  
		   
		    return week;   
		   
		}  
		function weektoday(monday,tuesday,wednesday,thursday,friday,saturday,sunday){  
   
		    var days=new Array();  
		   
		    var new_monday = changeTime(new Date(monday));//星期一  
		    var new_tuesday= changeTime(new Date(tuesday)); //星期二  
		    var new_wednesday = changeTime(new Date(wednesday)); //星期三  
		    var new_thursday = changeTime(new Date(thursday)); //星期四  
		    var new_friday= changeTime(new Date(friday)); //星期五  
		    var new_saturday = changeTime(new Date(saturday));//星期六  
		    var new_sunday = changeTime(new Date(sunday));//星期日  
		   
		    days[0]=new_monday;  
		    days[1]=new_tuesday;  
		    days[2]=new_wednesday;  
		    days[3]=new_thursday;  
		    days[4]=new_friday;  
		    days[5]=new_saturday;  
		    days[6]=new_sunday;  
		   
		    return days;  
		   
		} 
		function changeTime(str){  
		    var fullDate = "";  
		    var tmpMonth = "";  
		    var tmpDay = "";  
		    var tmpYear = "";  
		    tmpMonth = str.getMonth() + 1;  
		    if(tmpMonth < 10){  
		        tmpMonth = "0" + tmpMonth;  
		    }  
		    tmpDay = str.getDate();  
		    if(tmpDay < 10){  
		        tmpDay = "0" + tmpDay;  
		    }  
		    tmpYear = str.getFullYear();  
		    // return(+"/"++"/"+);  
		    return(tmpYear+'-'+tmpMonth+'-'+tmpDay);
		} 

		console.log(getThisWeekDate('2020-10-12'))
		console.log(getNextWeekDate('2024-05-09'))
	</script>
</body>
</html>